package com.cq.androidtools.room1

import androidx.room.Dao
import androidx.room.Query
import androidx.room.RoomWarnings
import androidx.room.Transaction

/**
 * 作者: CQ
 * 日期: 2021-05-12
 * 说明:
 */
@Dao
interface UserDao {
    @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
    @Transaction
    @Query("SELECT * from Student a where sId=:sId")
    fun getFromCompany(sId : Int) : List<Combination>

    @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
    @Transaction
    @Query("SELECT * from Student as a left join Make as b on a.sId = b.sId where a.age=:sId group by a.sId")
    fun getFromCompany1(sId : Int) : List<Combination>


    @Query("SELECT sum(cj) from Student as a left join Make as b on a.sId = b.sId where a.sId=:sId group by a.sId")
    fun selectCJ(sId: Int) : Int


    @Query("select sum(b.times) from Book as b left join Student as a on a.sId = b.studentId where a.sId = :sId group by b.studentId")
    fun selectTime(sId: Int) : Int
}